home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Toolkit / Songbird 0.1 / Songbird_0_1_0.exe / chrome / content / subscribe.xul < prev    next >
Extensible Markup Language  |  2006-02-07  |  12KB  |  278 lines

  1. <?xml version="1.0"?>
  2. <!--
  3. /*
  4. //
  5. // BEGIN SONGBIRD GPL
  6. // 
  7. // This file is part of the Songbird web player.
  8. //
  9. // Copyright┬⌐ 2006 Pioneers of the Inevitable LLC
  10. // http://songbirdnest.com
  11. // 
  12. // This file may be licensed under the terms of of the
  13. // GNU General Public License Version 2 (the ΓÇ£GPLΓÇ¥).
  14. // 
  15. // Software distributed under the License is distributed 
  16. // on an ΓÇ£AS ISΓÇ¥ basis, WITHOUT WARRANTY OF ANY KIND, either 
  17. // express or implied. See the GPL for the specific language 
  18. // governing rights and limitations.
  19. //
  20. // You should have received a copy of the GPL along with this 
  21. // program. If not, go to http://www.gnu.org/licenses/gpl.html
  22. // or write to the Free Software Foundation, Inc., 
  23. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  24. // 
  25. // END SONGBIRD GPL
  26. //
  27.  */
  28. -->
  29. <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
  30. <?xml-stylesheet href="chrome://rmp_demo/skin" type="text/css"?>
  31. <?xml-stylesheet href="chrome://rmp_demo/content/bindings/bindings.css" type="text/css"?>
  32. <!DOCTYPE window SYSTEM "chrome://rmp_demo/locale/rmp_demo.dtd" >
  33. <window
  34.  xmlns:html="http://www.w3.org/1999/xhtml"
  35.  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  36.  xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  37.  id="subscribe"
  38.  title="&subscribe.title;"
  39.  onload="doLoad();"
  40.  onkeypress="/* dialog key handling */ if ( event.keyCode == 13 ) { if ( doOK() ) onExit(); } else if ( event.keyCode == 27 ) { if ( doCancel() ) onExit(); }"
  41.  flex="1"
  42.  hidechrome="true"
  43. >
  44.  
  45.  
  46. <windowregion/>
  47. <stack flex="1">
  48.  
  49.   <vbox class="sb_faceplate" flex="1" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();">
  50.     <hbox class="sb_faceplate">
  51.         <image id="chrome_nw" class="sb_faceplate"/>
  52.         <image id="chrome_n" class="sb_faceplate" flex="1"/>
  53.         <image id="chrome_ne" class="sb_faceplate"/>
  54.     </hbox>
  55.     <hbox class="sb_faceplate" flex="1">
  56.         <image id="chrome_w" class="sb_faceplate"/>
  57.         <spacer onmousedown="onBkgDown( event );" onmouseup="onBkgUp();" flex="1"/>
  58.         <image id="chrome_e" class="sb_faceplate"/>
  59.     </hbox>
  60.     <hbox class="sb_faceplate">
  61.         <image id="chrome_sw" class="sb_faceplate"/>
  62.         <image id="chrome_s" class="sb_faceplate" flex="1"/>
  63.         <image id="chrome_se" class="sb_faceplate"/>
  64.     </hbox>
  65.   </vbox>
  66.   
  67.   <vbox class="sb_faceplate" flex="1">
  68.     <hbox class="sb_faceplate" id="frame_top_resizers">
  69.       <x_resizer id="frame_resize_to" dir="topleft" x_style="cursor: nw-resize;"/>
  70.       <x_resizer id="frame_resize_t" dir="top" x_style="cursor: n-resize;" flex="1"/>
  71.       <x_resizer id="frame_resize_to" dir="topright" x_style="cursor: ne-resize;"/>
  72.     </hbox>
  73.     <hbox class="sb_faceplate" flex="1">
  74.     
  75.     <hbox class="sb_faceplate" id="frame_middle_resizers" flex="1">
  76.       
  77.         <vbox class="sb_faceplate">
  78.           <x_resizer id="frame_resize_mo" dir="topleft" x_style="cursor: nw-resize;"/>
  79.           <x_resizer id="frame_resize_m" dir="left" x_style="cursor: w-resize;" flex="1"/>
  80.           <x_resizer id="frame_resize_mo" dir="bottomleft" x_style="cursor: sw-resize;"/>
  81.         </vbox>
  82.         
  83.         <vbox class="sb_faceplate" id="chrome_bkgd" flex="1">
  84.         
  85.           <hbox id="window_top" class="sb_faceplate" >
  86.             <label id="app_title" value="&subscribe.title;" class="sb_faceplate" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>
  87.             <spacer width="5" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>                    
  88.             <spacer flex="1" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>           
  89.             <spacer width="5" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>
  90.             <button id="sysbtn_close" class="sb_faceplate" oncommand="onExit( );" tooltiptext="&tooltip.exit;"/>
  91.           </hbox>
  92.         
  93.           <vbox flex="1">
  94.             
  95.             <hbox align="center">
  96.               <label class="dialog_label" value="URL:"/>
  97.               <textbox class="dialog_textbox" id="subscribe_url" value="http://"/>
  98.             </hbox>
  99.             <spacer height="5" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>
  100.             <hbox class="sb_faceplate" align="center">
  101.             <spacer width="40" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>
  102.             <checkbox class="dialog_checkbox" id="subscribe_autosubscribe_check" label="&subscribe.autocheck;" checked="true"/>
  103.             <textbox class="dialog_textbox" id="subscribe_interval" value="1"/>
  104.             <menulist id="subscribe_interval_unit" value="days">
  105.               <menupopup id="subscribe_interval_unit_popup">
  106.                 <menuitem id="subscribe_interval_days" label="&subscribe.days;" value="days"/>
  107.                 <menuitem id="subscribe_interval_hours" label="&subscribe.hours;" value="hours"/>
  108.                 <menuitem id="subscribe_interval_minutes" label="&subscribe.minutes;" value="minutes" />
  109.               </menupopup>
  110.             </menulist>
  111.             </hbox>
  112.             <spacer height="10" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>             
  113.             <label class="dialog_label" value="&subscribe.destinationfolder;"/>
  114.             <hbox>
  115.               <textbox class="dialog_textbox" id="subscribe_folder_path" flex="1"/>
  116.               <button id="button_browse" label="&window.browse;" class="dialog_button sb_faceplate" oncommand="doBrowse();"/>
  117.             </hbox>        
  118.           </vbox>
  119.           
  120.           <spacer height="8" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>           
  121.           
  122.           <hbox>
  123.             <spacer flex="1" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>           
  124.             <button id="button_ok" label="&window.ok;" class="dialog_button sb_faceplate" oncommand="if ( doOK() ) onExit( );"/>
  125.             <spacer width="5" onmousedown="onBkgDown( event );" onmouseup="onBkgUp();"/>
  126.             <button id="button_cancel" label="&window.cancel;" class="dialog_button sb_faceplate" oncommand="if ( doCancel() ) onExit( );"/>
  127.           </hbox>
  128.                 
  129.         </vbox>
  130.       
  131.         <vbox class="sb_faceplate">
  132.           <x_resizer id="frame_resize_mo" dir="topright" x_style="cursor: ne-resize;"/>
  133.           <x_resizer id="frame_resize_m" dir="right" x_style="cursor: e-resize;" flex="1"/>
  134.           <x_resizer id="frame_resize_mo" dir="bottomright" x_style="cursor: se-resize;"/>
  135.         </vbox>
  136.         
  137.       </hbox> <!-- frame_middle_resizers -->
  138.     </hbox>
  139.     <hbox class="sb_faceplate" id="frame_bottom_resizers">
  140.       <x_resizer id="frame_resize_to" dir="bottomleft" x_style="cursor: sw-resize;"/>
  141.       <x_resizer id="frame_resize_t" dir="bottom" x_style="cursor: s-resize;" flex="1"/>
  142.       <x_resizer id="frame_resize_to" dir="bottomright" x_style="cursor: se-resize;"/>
  143.     </hbox>
  144.   </vbox>
  145.  
  146.  
  147.    
  148. </stack>
  149.  
  150. <!-- SCRIPTS -->
  151. <script type="application/x-javascript" src="chrome://rmp_demo/content/rmp_demo.js" />
  152. <script type="application/x-javascript" src="chrome://rmp_demo/content/sbIDataRemote.js" />
  153. <script type="application/x-javascript" src="chrome://rmp_demo/content/songbird_interfaces.js" />
  154. <script type="application/x-javascript" src="chrome://rmp_demo/content/dynamic_playlist_updater.js" />
  155.   
  156.   <script>
  157.   <![CDATA[
  158.     function doLoad()
  159.     {
  160.       const SUBSCRIBE_FOLDER_KEY = "download.folder";
  161.       try
  162.       {
  163.         var theTextbox = document.getElementById( "subscribe_folder_path" );
  164.         theTextbox.value = SBDataGetValue( SUBSCRIBE_FOLDER_KEY );
  165.         var ok = document.getElementById( "button_ok" );
  166.         ok.focus();
  167.         if ( window.arguments && window.arguments[0] )
  168.         {
  169.           document.getElementById( "subscribe_url" ).value = window.arguments[0].url;
  170.         }
  171.       }
  172.       catch(err)
  173.       {
  174.         alert( "subscribe.xml - doLoad - " + err );
  175.       }
  176.     }
  177.     function doOK()
  178.     {
  179.       const SUBSCRIBE_FOLDER_KEY = "download.folder";
  180.       const PlaylistManager = new Components.Constructor("@songbird.org/Songbird/PlaylistManager;1", "sbIPlaylistManager");
  181.       try
  182.       {
  183.         var url = document.getElementById( "subscribe_url" ).value;
  184.         var time = parseInt( document.getElementById( "subscribe_interval" ).value );
  185.         var unit = document.getElementById("subscribe_interval_unit").value;
  186.         
  187.         if ( time == 0 )
  188.         {
  189.           return false;
  190.         }
  191.         
  192.         switch(unit)
  193.         {
  194.           case "days": time = time * 24 * 60; break;
  195.           case "hours": time = time * 60; break;
  196.         }
  197.         
  198.         var aPlaylistManager = (new PlaylistManager()).QueryInterface(Components.interfaces.sbIPlaylistManager);
  199.         var aDBQuery = Components.classes["@songbird.org/Songbird/DatabaseQuery;1"].createInstance(Components.interfaces.sbIDatabaseQuery);
  200.         aDBQuery.SetAsyncQuery( false );
  201.         aDBQuery.SetDatabaseGUID( "songbird" );
  202.         
  203.         var readable_name = getServer( url );
  204.         if ( window.arguments && window.arguments[0] && window.arguments[0].readable_name )
  205.         {
  206.           readable_name = window.arguments[0].readable_name + " ";
  207.         }
  208.     
  209.         var aUUIDGenerator = Components.classes["@mozilla.org/uuid-generator;1"].createInstance(Components.interfaces.nsIUUIDGenerator);
  210.         var guid = aUUIDGenerator.generateUUID();
  211.         
  212.         aPlaylistManager.CreateDynamicPlaylist(guid, readable_name, url, url, url, time, aDBQuery);
  213.  
  214.         var theTextbox = document.getElementById( "subscribe_folder_path" );
  215.         SBDataSetValue( SUBSCRIBE_FOLDER_KEY, theTextbox.value );
  216.  
  217.         //Run the dynamic playlist updater to download the new playlist.
  218.         SBDataFireEvent( "dynamic.playlist.update" );
  219.       
  220.         if ( window.arguments && window.arguments[0] )
  221.         {
  222.           window.arguments[0].value = theTextbox.value;
  223.           window.arguments[0].retval = "ok";
  224.         }
  225.       }
  226.       catch ( err )
  227.       {
  228.         alert( "subscribe.xul - doOK - " + err );
  229.       }
  230.       return true;
  231.     }
  232.     function doCancel()
  233.     {
  234.       if ( window.arguments && window.arguments[0] )
  235.       {
  236.         var theTextbox = document.getElementById( "subscribe_folder_path" );
  237.         window.arguments[0].value = theTextbox.value;
  238.         window.arguments[0].retval = "cancel";
  239.       }
  240.       return true;
  241.     }
  242.     function getServer( url )
  243.     {
  244.       retval = "";
  245.       try
  246.       {
  247.         var aURL = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURL);
  248.         aURL.spec = url;
  249.         var host = aURL.host;
  250.         var left = host.indexOf(".");
  251.         var right = host.lastIndexOf(".");
  252.         if ( left != right )
  253.         {
  254.           host = host.substr( left + 1, host.length );
  255.         }
  256.         retval = host;
  257.       }
  258.       catch (e) {}
  259.       return retval;
  260.     }
  261.     function doBrowse()
  262.     {
  263.       const CONTRACTID_FILE_PICKER = "@mozilla.org/filepicker;1";
  264.       var nsIFilePicker = Components.interfaces.nsIFilePicker;
  265.       var fp = Components.classes[CONTRACTID_FILE_PICKER].createInstance(nsIFilePicker);
  266.       fp.init( window, "", nsIFilePicker.modeGetFolder);
  267.       var res = fp.show();
  268.       if ( res == nsIFilePicker.returnOK )
  269.       {
  270.         var theTextbox = document.getElementById( "subscribe_folder_path" );
  271.         theTextbox.value = fp.file.path;
  272.       }
  273.     }
  274.   ]]>
  275.   </script>
  276.   
  277.   
  278. </window>